clear
set mem 200m
use "C:\Users\spiston\Dropbox\Non-project stuff\Grants\BITSS Sloan\Kalmoe and Piston 2013 POQ replication\ANES 2008-09 Panel\ANES 2008-09 Panel.dta" 
set more off

//AMP-recode the var that specifies whether Obama-McCain or white-black was used in9th wave (rather than 10th)*
gen ampverobama=w9amp_ve
recode ampverobama -6/-2=. 2=0

//AMP-make it the blackwhite version
gen ampverbw=w9amp_ve
recode ampverbw -6/-2=. 1=0 2=1

//AMP
gen black1=w9amp_50 if w9amp_ve==2
replace black1=w10am_50 if w10amp_v==1
recode black1 1=1 2=0 else=.
gen black1miss=w9amp_50 if w9amp_ve==2
replace black1miss=w10am_50 if w10amp_v==1
recode black1miss -7 -6 -2=1 else=0
gen black2=w9amp_51 if w9amp_ve==2
replace black2=w10am_51 if w10amp_v==1
recode black2 1=1 2=0 else=.
gen black2miss=w9amp_51 if w9amp_ve==2
replace black2miss=w10am_51 if w10amp_v==1
recode black2miss -7 -6 -2=1 else=0
gen black3=w9amp_52 if w9amp_ve==2
replace black3=w10am_52 if w10amp_v==1
recode black3 1=1 2=0 else=.
gen black3miss=w9amp_52 if w9amp_ve==2
replace black3miss=w10am_52 if w10amp_v==1
recode black3miss -7 -6 -2=1 else=0
gen black4=w9amp_53 if w9amp_ve==2
replace black4=w10am_53 if w10amp_v==1
recode black4 1=1 2=0 else=.
gen black4miss=w9amp_53 if w9amp_ve==2
replace black4miss=w10am_53 if w10amp_v==1
recode black4miss -7 -6 -2=1 else=0
gen black5=w9amp_54 if w9amp_ve==2
replace black5=w10am_54 if w10amp_v==1
recode black5 1=1 2=0 else=.
gen black5miss=w9amp_54 if w9amp_ve==2
replace black5miss=w10am_54 if w10amp_v==1
recode black5miss -7 -6 -2=1 else=0
gen black6=w9amp_55 if w9amp_ve==2
replace black6=w10am_55 if w10amp_v==1
recode black6 1=1 2=0 else=.
gen black6miss=w9amp_55 if w9amp_ve==2
replace black6miss=w10am_55 if w10amp_v==1
recode black6miss -7 -6 -2=1 else=0
gen black7=w9amp_56 if w9amp_ve==2
replace black7=w10am_56 if w10amp_v==1
recode black7 1=1 2=0 else=.
gen black7miss=w9amp_56 if w9amp_ve==2
replace black7miss=w10am_56 if w10amp_v==1
recode black7miss -7 -6 -2=1 else=0
gen black8=w9amp_57 if w9amp_ve==2
replace black8=w10am_57 if w10amp_v==1
recode black8 1=1 2=0 else=.
gen black8miss=w9amp_57 if w9amp_ve==2
replace black8miss=w10am_57 if w10amp_v==1
recode black8miss -7 -6 -2=1 else=0
gen black9=w9amp_58 if w9amp_ve==2
replace black9=w10am_58 if w10amp_v==1
recode black9 1=1 2=0 else=.
gen black9miss=w9amp_58 if w9amp_ve==2
replace black9miss=w10am_58 if w10amp_v==1
recode black9miss -7 -6 -2=1 else=0
gen black10=w9amp_59 if w9amp_ve==2
replace black10=w10am_59 if w10amp_v==1
recode black10 1=1 2=0 else=.
gen black10miss=w9amp_59 if w9amp_ve==2
replace black10miss=w10am_59 if w10amp_v==1
recode black10miss -7 -6 -2=1 else=0
gen black11=w9amp_60 if w9amp_ve==2
replace black11=w10am_60 if w10amp_v==1
recode black11 1=1 2=0 else=.
gen black11miss=w9amp_60 if w9amp_ve==2
replace black11miss=w10am_60 if w10amp_v==1
recode black11miss -7 -6 -2=1 else=0
gen black12=w9amp_61 if w9amp_ve==2
replace black12=w10am_61 if w10amp_v==1
recode black12 1=1 2=0 else=.
gen black12miss=w9amp_61 if w9amp_ve==2
replace black12miss=w10am_61 if w10amp_v==1
recode black12miss -7 -6 -2=1 else=0
gen black13=w9amp_62 if w9amp_ve==2
replace black13=w10am_62 if w10amp_v==1
recode black13 1=1 2=0 else=.
gen black13miss=w9amp_62 if w9amp_ve==2
replace black13miss=w10am_62 if w10amp_v==1
recode black13miss -7 -6 -2=1 else=0
gen black14=w9amp_63 if w9amp_ve==2
replace black14=w10am_63 if w10amp_v==1
recode black14 1=1 2=0 else=.
gen black14miss=w9amp_63 if w9amp_ve==2
replace black14miss=w10am_63 if w10amp_v==1
recode black14miss -7 -6 -2=1 else=0
gen black15=w9amp_64 if w9amp_ve==2
replace black15=w10am_64 if w10amp_v==1
recode black15 1=1 2=0 else=.
gen black15miss=w9amp_64 if w9amp_ve==2
replace black15miss=w10am_64 if w10amp_v==1
recode black15miss -7 -6 -2=1 else=0
gen black16=w9amp_65 if w9amp_ve==2
replace black16=w10am_65 if w10amp_v==1
recode black16 1=1 2=0 else=.
gen black16miss=w9amp_65 if w9amp_ve==2
replace black16miss=w10am_65 if w10amp_v==1
recode black16miss -7 -6 -2=1 else=0
gen black17=w9amp_66 if w9amp_ve==2
replace black17=w10am_66 if w10amp_v==1
recode black17 1=1 2=0 else=.
gen black17miss=w9amp_66 if w9amp_ve==2
replace black17miss=w10am_66 if w10amp_v==1
recode black17miss -7 -6 -2=1 else=0
gen black18=w9amp_67 if w9amp_ve==2
replace black18=w10am_67 if w10amp_v==1
recode black18 1=1 2=0 else=.
gen black18miss=w9amp_67 if w9amp_ve==2
replace black18miss=w10am_67 if w10amp_v==1
recode black18miss -7 -6 -2=1 else=0
gen black19=w9amp_68 if w9amp_ve==2
replace black19=w10am_68 if w10amp_v==1
recode black19 1=1 2=0 else=.
gen black19miss=w9amp_68 if w9amp_ve==2
replace black19miss=w10am_68 if w10amp_v==1
recode black19miss -7 -6 -2=1 else=0
gen black20=w9amp_69 if w9amp_ve==2
replace black20=w10am_69 if w10amp_v==1
recode black20 1=1 2=0 else=.
gen black20miss=w9amp_69 if w9amp_ve==2
replace black20miss=w10am_69 if w10amp_v==1
recode black20miss -7 -6 -2=1 else=0
gen black21=w9amp_70 if w9amp_ve==2
replace black21=w10am_70 if w10amp_v==1
recode black21 1=1 2=0 else=.
gen black21miss=w9amp_70 if w9amp_ve==2
replace black21miss=w10am_70 if w10amp_v==1
recode black21miss -7 -6 -2=1 else=0
gen black22=w9amp_71 if w9amp_ve==2
replace black22=w10am_71 if w10amp_v==1
recode black22 1=1 2=0 else=.
gen black22miss=w9amp_71 if w9amp_ve==2
replace black22miss=w10am_71 if w10amp_v==1
recode black22miss -7 -6 -2=1 else=0
gen black23=w9amp_72 if w9amp_ve==2
replace black23=w10am_72 if w10amp_v==1
recode black23 1=1 2=0 else=.
gen black23miss=w9amp_72 if w9amp_ve==2
replace black23miss=w10am_72 if w10amp_v==1
recode black23miss -7 -6 -2=1 else=0
gen black24=w9amp_73 if w9amp_ve==2
replace black24=w10am_73 if w10amp_v==1
recode black24 1=1 2=0 else=.
gen black24miss=w9amp_73 if w9amp_ve==2
replace black24miss=w10am_73 if w10amp_v==1
recode black24miss -7 -6 -2=1 else=0

gen blackmiss=(black1miss+black2miss+black3miss+black4miss+black5miss+black6miss+black7miss+black8miss+black9miss+black10miss+black11miss+black12miss+black13miss+black14miss+black15miss+black16miss+black17miss+black18miss+black19miss+black20miss+black21miss+black22miss+black23miss+black24miss)

gen white1=w9amp_74 if w9amp_ve==2
replace white1=w10am_74 if w10amp_v==1
recode white1 1=1 2=0 else=.
gen white1miss=w9amp_74 if w9amp_ve==2
replace white1miss=w10am_74 if w10amp_v==1
recode white1miss -7 -6 -2=1 else=0
gen white2=w9amp_75 if w9amp_ve==2
replace white2=w10am_75 if w10amp_v==1
recode white2 1=1 2=0 else=.
gen white2miss=w9amp_75 if w9amp_ve==2
replace white2miss=w10am_75 if w10amp_v==1
recode white2miss -7 -6 -2=1 else=0
gen white3=w9amp_76 if w9amp_ve==2
replace white3=w10am_76 if w10amp_v==1
recode white3 1=1 2=0 else=.
gen white3miss=w9amp_76 if w9amp_ve==2
replace white3miss=w10am_76 if w10amp_v==1
recode white3miss -7 -6 -2=1 else=0
gen white4=w9amp_77 if w9amp_ve==2
replace white4=w10am_77 if w10amp_v==1
recode white4 1=1 2=0 else=.
gen white4miss=w9amp_77 if w9amp_ve==2
replace white4miss=w10am_77 if w10amp_v==1
recode white4miss -7 -6 -2=1 else=0
gen white5=w9amp_78 if w9amp_ve==2
replace white5=w10am_78 if w10amp_v==1
recode white5 1=1 2=0 else=.
gen white5miss=w9amp_78 if w9amp_ve==2
replace white5miss=w10am_78 if w10amp_v==1
recode white5miss -7 -6 -2=1 else=0
gen white6=w9amp_79 if w9amp_ve==2
replace white6=w10am_79 if w10amp_v==1
recode white6 1=1 2=0 else=.
gen white6miss=w9amp_79 if w9amp_ve==2
replace white6miss=w10am_79 if w10amp_v==1
recode white6miss -7 -6 -2=1 else=0
gen white7=w9amp_80 if w9amp_ve==2
replace white7=w10am_80 if w10amp_v==1
recode white7 1=1 2=0 else=.
gen white7miss=w9amp_80 if w9amp_ve==2
replace white7miss=w10am_80 if w10amp_v==1
recode white7miss -7 -6 -2=1 else=0
gen white8=w9amp_81 if w9amp_ve==2
replace white8=w10am_81 if w10amp_v==1
recode white8 1=1 2=0 else=.
gen white8miss=w9amp_81 if w9amp_ve==2
replace white8miss=w10am_81 if w10amp_v==1
recode white8miss -7 -6 -2=1 else=0
gen white9=w9amp_82 if w9amp_ve==2
replace white9=w10am_82 if w10amp_v==1
recode white9 1=1 2=0 else=.
gen white9miss=w9amp_82 if w9amp_ve==2
replace white9miss=w10am_82 if w10amp_v==1
recode white9miss -7 -6 -2=1 else=0
gen white10=w9amp_83 if w9amp_ve==2
replace white10=w10am_83 if w10amp_v==1
recode white10 1=1 2=0 else=.
gen white10miss=w9amp_83 if w9amp_ve==2
replace white10miss=w10am_83 if w10amp_v==1
recode white10miss -7 -6 -2=1 else=0
gen white11=w9amp_84 if w9amp_ve==2
replace white11=w10am_84 if w10amp_v==1
recode white11 1=1 2=0 else=.
gen white11miss=w9amp_84 if w9amp_ve==2
replace white11miss=w10am_84 if w10amp_v==1
recode white11miss -7 -6 -2=1 else=0
gen white12=w9amp_85 if w9amp_ve==2
replace white12=w10am_85 if w10amp_v==1
recode white12 1=1 2=0 else=.
gen white12miss=w9amp_85 if w9amp_ve==2
replace white12miss=w10am_85 if w10amp_v==1
recode white12miss -7 -6 -2=1 else=0
gen white13=w9amp_86 if w9amp_ve==2
replace white13=w10am_86 if w10amp_v==1
recode white13 1=1 2=0 else=.
gen white13miss=w9amp_86 if w9amp_ve==2
replace white13miss=w10am_86 if w10amp_v==1
recode white13miss -7 -6 -2=1 else=0
gen white14=w9amp_87 if w9amp_ve==2
replace white14=w10am_87 if w10amp_v==1
recode white14 1=1 2=0 else=.
gen white14miss=w9amp_87 if w9amp_ve==2
replace white14miss=w10am_87 if w10amp_v==1
recode white14miss -7 -6 -2=1 else=0
gen white15=w9amp_88 if w9amp_ve==2
replace white15=w10am_88 if w10amp_v==1
recode white15 1=1 2=0 else=.
gen white15miss=w9amp_88 if w9amp_ve==2
replace white15miss=w10am_88 if w10amp_v==1
recode white15miss -7 -6 -2=1 else=0
gen white16=w9amp_89 if w9amp_ve==2
replace white16=w10am_89 if w10amp_v==1
recode white16 1=1 2=0 else=.
gen white16miss=w9amp_89 if w9amp_ve==2
replace white16miss=w10am_89 if w10amp_v==1
recode white16miss -7 -6 -2=1 else=0
gen white17=w9amp_90 if w9amp_ve==2
replace white17=w10am_90 if w10amp_v==1
recode white17 1=1 2=0 else=.
gen white17miss=w9amp_90 if w9amp_ve==2
replace white17miss=w10am_90 if w10amp_v==1
recode white17miss -7 -6 -2=1 else=0
gen white18=w9amp_91 if w9amp_ve==2
replace white18=w10am_91 if w10amp_v==1
recode white18 1=1 2=0 else=.
gen white18miss=w9amp_91 if w9amp_ve==2
replace white18miss=w10am_91 if w10amp_v==1
recode white18miss -7 -6 -2=1 else=0
gen white19=w9amp_92 if w9amp_ve==2
replace white19=w10am_92 if w10amp_v==1
recode white19 1=1 2=0 else=.
gen white19miss=w9amp_92 if w9amp_ve==2
replace white19miss=w10am_92 if w10amp_v==1
recode white19miss -7 -6 -2=1 else=0
gen white20=w9amp_93 if w9amp_ve==2
replace white20=w10am_93 if w10amp_v==1
recode white20 1=1 2=0 else=.
gen white20miss=w9amp_93 if w9amp_ve==2
replace white20miss=w10am_93 if w10amp_v==1
recode white20miss -7 -6 -2=1 else=0
gen white21=w9amp_94 if w9amp_ve==2
replace white21=w10am_94 if w10amp_v==1
recode white21 1=1 2=0 else=.
gen white21miss=w9amp_94 if w9amp_ve==2
replace white21miss=w10am_94 if w10amp_v==1
recode white21miss -7 -6 -2=1 else=0
gen white22=w9amp_95 if w9amp_ve==2
replace white22=w10am_95 if w10amp_v==1
recode white22 1=1 2=0 else=.
gen white22miss=w9amp_95 if w9amp_ve==2
replace white22miss=w10am_95 if w10amp_v==1
recode white22miss -7 -6 -2=1 else=0
gen white23=w9amp_96 if w9amp_ve==2
replace white23=w10am_96 if w10amp_v==1
recode white23 1=1 2=0 else=.
gen white23miss=w9amp_96 if w9amp_ve==2
replace white23miss=w10am_96 if w10amp_v==1
recode white23miss -7 -6 -2=1 else=0
gen white24=w9amp_97 if w9amp_ve==2
replace white24=w10am_97 if w10amp_v==1
recode white24 1=1 2=0 else=.
gen white24miss=w9amp_97 if w9amp_ve==2
replace white24miss=w10am_97 if w10amp_v==1
recode white24miss -7 -6 -2=1 else=0
gen whitemiss=(white1miss+white2miss+white3miss+white4miss+white5miss+white6miss+white7miss+white8miss+white9miss+white10miss+white11miss+white12miss+white13miss+white14miss+white15miss+white16miss+white17miss+white18miss+white19miss+white20miss+white21miss+white22miss+white23miss+white24miss)

gen amp1=(1+white1-black1)/2
gen amp2=(1+white2-black2)/2
gen amp3=(1+white3-black3)/2
gen amp4=(1+white4-black4)/2
gen amp5=(1+white5-black5)/2
gen amp6=(1+white6-black6)/2
gen amp7=(1+white7-black7)/2
gen amp8=(1+white8-black8)/2
gen amp9=(1+white9-black9)/2
gen amp10=(1+white10-black10)/2
gen amp11=(1+white11-black11)/2
gen amp12=(1+white12-black12)/2
gen amp13=(1+white13-black13)/2
gen amp14=(1+white14-black14)/2
gen amp15=(1+white15-black15)/2
gen amp16=(1+white16-black16)/2
gen amp17=(1+white17-black17)/2
gen amp18=(1+white18-black18)/2
gen amp19=(1+white19-black19)/2
gen amp20=(1+white20-black20)/2
gen amp21=(1+white21-black21)/2
gen amp22=(1+white22-black22)/2
gen amp23=(1+white23-black23)/2
gen amp24=(1+white24-black24)/2

recode black1 .=0 if black1miss==1
recode black2 .=0 if black2miss==1
recode black3 .=0 if black3miss==1
recode black4 .=0 if black4miss==1
recode black5 .=0 if black5miss==1
recode black6 .=0 if black6miss==1
recode black7 .=0 if black7miss==1
recode black8 .=0 if black8miss==1
recode black9 .=0 if black9miss==1
recode black10 .=0 if black10miss==1
recode black11 .=0 if black11miss==1
recode black12 .=0 if black12miss==1
recode black13 .=0 if black13miss==1
recode black14 .=0 if black14miss==1
recode black15 .=0 if black15miss==1
recode black16 .=0 if black16miss==1
recode black17 .=0 if black17miss==1
recode black18 .=0 if black18miss==1
recode black19 .=0 if black19miss==1
recode black20 .=0 if black20miss==1
recode black21 .=0 if black21miss==1
recode black22 .=0 if black22miss==1
recode black23 .=0 if black23miss==1
recode black24 .=0 if black24miss==1

recode white1 .=0 if white1miss==1
recode white2 .=0 if white2miss==1
recode white3 .=0 if white3miss==1
recode white4 .=0 if white4miss==1
recode white5 .=0 if white5miss==1
recode white6 .=0 if white6miss==1
recode white7 .=0 if white7miss==1
recode white8 .=0 if white8miss==1
recode white9 .=0 if white9miss==1
recode white10 .=0 if white10miss==1
recode white11 .=0 if white11miss==1
recode white12 .=0 if white12miss==1
recode white13 .=0 if white13miss==1
recode white14 .=0 if white14miss==1
recode white15 .=0 if white15miss==1
recode white16 .=0 if white16miss==1
recode white17 .=0 if white17miss==1
recode white18 .=0 if white18miss==1
recode white19 .=0 if white19miss==1
recode white20 .=0 if white20miss==1
recode white21 .=0 if white21miss==1
recode white22 .=0 if white22miss==1
recode white23 .=0 if white23miss==1
recode white24 .=0 if white24miss==1

gen blacktotal=(black1+black2+black3+black4+black5+black6+black7+black8+black9+black10+black11+black12+black13+black14+black15+black16+black17+black18+black19+black20+black21+black22+black23+black24)/(24-blackmiss) if blackmiss<2
gen whitetotal=(white1+white2+white3+white4+white5+white6+white7+white8+white9+white10+white11+white12+white13+white14+white15+white16+white17+white18+white19+white20+white21+white22+white23+white24)/(24-whitemiss) if whitemiss<2

gen amp=(1+whitetotal-blacktotal)/2

gen obama1=w9amp_50 if w9amp_ve==1
replace obama1=w10am_50 if w10amp_v==2
recode obama1 1=1 2=0 else=.
gen obama1miss=w9amp_50 if w9amp_ve==1
replace obama1miss=w10am_50 if w10amp_v==2
recode obama1miss -7 -6 -2=1 else=0
gen obama2=w9amp_51 if w9amp_ve==1
replace obama2=w10am_51 if w10amp_v==2
recode obama2 1=1 2=0 else=.
gen obama2miss=w9amp_51 if w9amp_ve==1
replace obama2miss=w10am_51 if w10amp_v==2
recode obama2miss -7 -6 -2=1 else=0
gen obama3=w9amp_52 if w9amp_ve==1
replace obama3=w10am_52 if w10amp_v==2
recode obama3 1=1 2=0 else=.
gen obama3miss=w9amp_52 if w9amp_ve==1
replace obama3miss=w10am_52 if w10amp_v==2
recode obama3miss -7 -6 -2=1 else=0
gen obama4=w9amp_53 if w9amp_ve==1
replace obama4=w10am_53 if w10amp_v==2
recode obama4 1=1 2=0 else=.
gen obama4miss=w9amp_53 if w9amp_ve==1
replace obama4miss=w10am_53 if w10amp_v==2
recode obama4miss -7 -6 -2=1 else=0
gen obama5=w9amp_54 if w9amp_ve==1
replace obama5=w10am_54 if w10amp_v==2
recode obama5 1=1 2=0 else=.
gen obama5miss=w9amp_54 if w9amp_ve==1
replace obama5miss=w10am_54 if w10amp_v==2
recode obama5miss -7 -6 -2=1 else=0
gen obama6=w9amp_55 if w9amp_ve==1
replace obama6=w10am_55 if w10amp_v==2
recode obama6 1=1 2=0 else=.
gen obama6miss=w9amp_55 if w9amp_ve==1
replace obama6miss=w10am_55 if w10amp_v==2
recode obama6miss -7 -6 -2=1 else=0
gen obama7=w9amp_56 if w9amp_ve==1
replace obama7=w10am_56 if w10amp_v==2
recode obama7 1=1 2=0 else=.
gen obama7miss=w9amp_56 if w9amp_ve==1
replace obama7miss=w10am_56 if w10amp_v==2
recode obama7miss -7 -6 -2=1 else=0
gen obama8=w9amp_57 if w9amp_ve==1
replace obama8=w10am_57 if w10amp_v==2
recode obama8 1=1 2=0 else=.
gen obama8miss=w9amp_57 if w9amp_ve==1
replace obama8miss=w10am_57 if w10amp_v==2
recode obama8miss -7 -6 -2=1 else=0
gen obama9=w9amp_58 if w9amp_ve==1
replace obama9=w10am_58 if w10amp_v==2
recode obama9 1=1 2=0 else=.
gen obama9miss=w9amp_58 if w9amp_ve==1
replace obama9miss=w10am_58 if w10amp_v==2
recode obama9miss -7 -6 -2=1 else=0
gen obama10=w9amp_59 if w9amp_ve==1
replace obama10=w10am_59 if w10amp_v==2
recode obama10 1=1 2=0 else=.
gen obama10miss=w9amp_59 if w9amp_ve==1
replace obama10miss=w10am_59 if w10amp_v==2
recode obama10miss -7 -6 -2=1 else=0
gen obama11=w9amp_60 if w9amp_ve==1
replace obama11=w10am_60 if w10amp_v==2
recode obama11 1=1 2=0 else=.
gen obama11miss=w9amp_60 if w9amp_ve==1
replace obama11miss=w10am_60 if w10amp_v==2
recode obama11miss -7 -6 -2=1 else=0
gen obama12=w9amp_61 if w9amp_ve==1
replace obama12=w10am_61 if w10amp_v==2
recode obama12 1=1 2=0 else=.
gen obama12miss=w9amp_61 if w9amp_ve==1
replace obama12miss=w10am_61 if w10amp_v==2
recode obama12miss -7 -6 -2=1 else=0
gen obama13=w9amp_62 if w9amp_ve==1
replace obama13=w10am_62 if w10amp_v==2
recode obama13 1=1 2=0 else=.
gen obama13miss=w9amp_62 if w9amp_ve==1
replace obama13miss=w10am_62 if w10amp_v==2
recode obama13miss -7 -6 -2=1 else=0
gen obama14=w9amp_63 if w9amp_ve==1
replace obama14=w10am_63 if w10amp_v==2
recode obama14 1=1 2=0 else=.
gen obama14miss=w9amp_63 if w9amp_ve==1
replace obama14miss=w10am_63 if w10amp_v==2
recode obama14miss -7 -6 -2=1 else=0
gen obama15=w9amp_64 if w9amp_ve==1
replace obama15=w10am_64 if w10amp_v==2
recode obama15 1=1 2=0 else=.
gen obama15miss=w9amp_64 if w9amp_ve==1
replace obama15miss=w10am_64 if w10amp_v==2
recode obama15miss -7 -6 -2=1 else=0
gen obama16=w9amp_65 if w9amp_ve==1
replace obama16=w10am_65 if w10amp_v==2
recode obama16 1=1 2=0 else=.
gen obama16miss=w9amp_65 if w9amp_ve==1
replace obama16miss=w10am_65 if w10amp_v==2
recode obama16miss -7 -6 -2=1 else=0
gen obama17=w9amp_66 if w9amp_ve==1
replace obama17=w10am_66 if w10amp_v==2
recode obama17 1=1 2=0 else=.
gen obama17miss=w9amp_66 if w9amp_ve==1
replace obama17miss=w10am_66 if w10amp_v==2
recode obama17miss -7 -6 -2=1 else=0
gen obama18=w9amp_67 if w9amp_ve==1
replace obama18=w10am_67 if w10amp_v==2
recode obama18 1=1 2=0 else=.
gen obama18miss=w9amp_67 if w9amp_ve==1
replace obama18miss=w10am_67 if w10amp_v==2
recode obama18miss -7 -6 -2=1 else=0
gen obama19=w9amp_68 if w9amp_ve==1
replace obama19=w10am_68 if w10amp_v==2
recode obama19 1=1 2=0 else=.
gen obama19miss=w9amp_68 if w9amp_ve==1
replace obama19miss=w10am_68 if w10amp_v==2
recode obama19miss -7 -6 -2=1 else=0
gen obama20=w9amp_69 if w9amp_ve==1
replace obama20=w10am_69 if w10amp_v==2
recode obama20 1=1 2=0 else=.
gen obama20miss=w9amp_69 if w9amp_ve==1
replace obama20miss=w10am_69 if w10amp_v==2
recode obama20miss -7 -6 -2=1 else=0
gen obama21=w9amp_70 if w9amp_ve==1
replace obama21=w10am_70 if w10amp_v==2
recode obama21 1=1 2=0 else=.
gen obama21miss=w9amp_70 if w9amp_ve==1
replace obama21miss=w10am_70 if w10amp_v==2
recode obama21miss -7 -6 -2=1 else=0
gen obama22=w9amp_71 if w9amp_ve==1
replace obama22=w10am_71 if w10amp_v==2
recode obama22 1=1 2=0 else=.
gen obama22miss=w9amp_71 if w9amp_ve==1
replace obama22miss=w10am_71 if w10amp_v==2
recode obama22miss -7 -6 -2=1 else=0
gen obama23=w9amp_72 if w9amp_ve==1
replace obama23=w10am_72 if w10amp_v==2
recode obama23 1=1 2=0 else=.
gen obama23miss=w9amp_72 if w9amp_ve==1
replace obama23miss=w10am_72 if w10amp_v==2
recode obama23miss -7 -6 -2=1 else=0
gen obama24=w9amp_73 if w9amp_ve==1
replace obama24=w10am_73 if w10amp_v==2
recode obama24 1=1 2=0 else=.
gen obama24miss=w9amp_73 if w9amp_ve==1
replace obama24miss=w10am_73 if w10amp_v==2
recode obama24miss -7 -6 -2=1 else=0

gen obamamiss=(obama1miss+obama2miss+obama3miss+obama4miss+obama5miss+obama6miss+obama7miss+obama8miss+obama9miss+obama10miss+obama11miss+obama12miss+obama13miss+obama14miss+obama15miss+obama16miss+obama17miss+obama18miss+obama19miss+obama20miss+obama21miss+obama22miss+obama23miss+obama24miss)

gen mccain1=w9amp_74 if w9amp_ve==1
replace mccain1=w10am_74 if w10amp_v==2
recode mccain1 1=1 2=0 else=.
gen mccain1miss=w9amp_74 if w9amp_ve==1
replace mccain1miss=w10am_74 if w10amp_v==2
recode mccain1miss -7 -6 -2=1 else=0
gen mccain2=w9amp_75 if w9amp_ve==1
replace mccain2=w10am_75 if w10amp_v==2
recode mccain2 1=1 2=0 else=.
gen mccain2miss=w9amp_75 if w9amp_ve==1
replace mccain2miss=w10am_75 if w10amp_v==2
recode mccain2miss -7 -6 -2=1 else=0
gen mccain3=w9amp_76 if w9amp_ve==1
replace mccain3=w10am_76 if w10amp_v==2
recode mccain3 1=1 2=0 else=.
gen mccain3miss=w9amp_76 if w9amp_ve==1
replace mccain3miss=w10am_76 if w10amp_v==2
recode mccain3miss -7 -6 -2=1 else=0
gen mccain4=w9amp_77 if w9amp_ve==1
replace mccain4=w10am_77 if w10amp_v==2
recode mccain4 1=1 2=0 else=.
gen mccain4miss=w9amp_77 if w9amp_ve==1
replace mccain4miss=w10am_77 if w10amp_v==2
recode mccain4miss -7 -6 -2=1 else=0
gen mccain5=w9amp_78 if w9amp_ve==1
replace mccain5=w10am_78 if w10amp_v==2
recode mccain5 1=1 2=0 else=.
gen mccain5miss=w9amp_78 if w9amp_ve==1
replace mccain5miss=w10am_78 if w10amp_v==2
recode mccain5miss -7 -6 -2=1 else=0
gen mccain6=w9amp_79 if w9amp_ve==1
replace mccain6=w10am_79 if w10amp_v==2
recode mccain6 1=1 2=0 else=.
gen mccain6miss=w9amp_79 if w9amp_ve==1
replace mccain6miss=w10am_79 if w10amp_v==2
recode mccain6miss -7 -6 -2=1 else=0
gen mccain7=w9amp_80 if w9amp_ve==1
replace mccain7=w10am_80 if w10amp_v==2
recode mccain7 1=1 2=0 else=.
gen mccain7miss=w9amp_80 if w9amp_ve==1
replace mccain7miss=w10am_80 if w10amp_v==2
recode mccain7miss -7 -6 -2=1 else=0
gen mccain8=w9amp_81 if w9amp_ve==1
replace mccain8=w10am_81 if w10amp_v==2
recode mccain8 1=1 2=0 else=.
gen mccain8miss=w9amp_81 if w9amp_ve==1
replace mccain8miss=w10am_81 if w10amp_v==2
recode mccain8miss -7 -6 -2=1 else=0
gen mccain9=w9amp_82 if w9amp_ve==1
replace mccain9=w10am_82 if w10amp_v==2
recode mccain9 1=1 2=0 else=.
gen mccain9miss=w9amp_82 if w9amp_ve==1
replace mccain9miss=w10am_82 if w10amp_v==2
recode mccain9miss -7 -6 -2=1 else=0
gen mccain10=w9amp_83 if w9amp_ve==1
replace mccain10=w10am_83 if w10amp_v==2
recode mccain10 1=1 2=0 else=.
gen mccain10miss=w9amp_83 if w9amp_ve==1
replace mccain10miss=w10am_83 if w10amp_v==2
recode mccain10miss -7 -6 -2=1 else=0
gen mccain11=w9amp_84 if w9amp_ve==1
replace mccain11=w10am_84 if w10amp_v==2
recode mccain11 1=1 2=0 else=.
gen mccain11miss=w9amp_84 if w9amp_ve==1
replace mccain11miss=w10am_84 if w10amp_v==2
recode mccain11miss -7 -6 -2=1 else=0
gen mccain12=w9amp_85 if w9amp_ve==1
replace mccain12=w10am_85 if w10amp_v==2
recode mccain12 1=1 2=0 else=.
gen mccain12miss=w9amp_85 if w9amp_ve==1
replace mccain12miss=w10am_85 if w10amp_v==2
recode mccain12miss -7 -6 -2=1 else=0
gen mccain13=w9amp_86 if w9amp_ve==1
replace mccain13=w10am_86 if w10amp_v==2
recode mccain13 1=1 2=0 else=.
gen mccain13miss=w9amp_86 if w9amp_ve==1
replace mccain13miss=w10am_86 if w10amp_v==2
recode mccain13miss -7 -6 -2=1 else=0
gen mccain14=w9amp_87 if w9amp_ve==1
replace mccain14=w10am_87 if w10amp_v==2
recode mccain14 1=1 2=0 else=.
gen mccain14miss=w9amp_87 if w9amp_ve==1
replace mccain14miss=w10am_87 if w10amp_v==2
recode mccain14miss -7 -6 -2=1 else=0
gen mccain15=w9amp_88 if w9amp_ve==1
replace mccain15=w10am_88 if w10amp_v==2
recode mccain15 1=1 2=0 else=.
gen mccain15miss=w9amp_88 if w9amp_ve==1
replace mccain15miss=w10am_88 if w10amp_v==2
recode mccain15miss -7 -6 -2=1 else=0
gen mccain16=w9amp_89 if w9amp_ve==1
replace mccain16=w10am_89 if w10amp_v==2
recode mccain16 1=1 2=0 else=.
gen mccain16miss=w9amp_89 if w9amp_ve==1
replace mccain16miss=w10am_89 if w10amp_v==2
recode mccain16miss -7 -6 -2=1 else=0
gen mccain17=w9amp_90 if w9amp_ve==1
replace mccain17=w10am_90 if w10amp_v==2
recode mccain17 1=1 2=0 else=.
gen mccain17miss=w9amp_90 if w9amp_ve==1
replace mccain17miss=w10am_90 if w10amp_v==2
recode mccain17miss -7 -6 -2=1 else=0
gen mccain18=w9amp_91 if w9amp_ve==1
replace mccain18=w10am_91 if w10amp_v==2
recode mccain18 1=1 2=0 else=.
gen mccain18miss=w9amp_91 if w9amp_ve==1
replace mccain18miss=w10am_91 if w10amp_v==2
recode mccain18miss -7 -6 -2=1 else=0
gen mccain19=w9amp_92 if w9amp_ve==1
replace mccain19=w10am_92 if w10amp_v==2
recode mccain19 1=1 2=0 else=.
gen mccain19miss=w9amp_92 if w9amp_ve==1
replace mccain19miss=w10am_92 if w10amp_v==2
recode mccain19miss -7 -6 -2=1 else=0
gen mccain20=w9amp_93 if w9amp_ve==1
replace mccain20=w10am_93 if w10amp_v==2
recode mccain20 1=1 2=0 else=.
gen mccain20miss=w9amp_93 if w9amp_ve==1
replace mccain20miss=w10am_93 if w10amp_v==2
recode mccain20miss -7 -6 -2=1 else=0
gen mccain21=w9amp_94 if w9amp_ve==1
replace mccain21=w10am_94 if w10amp_v==2
recode mccain21 1=1 2=0 else=.
gen mccain21miss=w9amp_94 if w9amp_ve==1
replace mccain21miss=w10am_94 if w10amp_v==2
recode mccain21miss -7 -6 -2=1 else=0
gen mccain22=w9amp_95 if w9amp_ve==1
replace mccain22=w10am_95 if w10amp_v==2
recode mccain22 1=1 2=0 else=.
gen mccain22miss=w9amp_95 if w9amp_ve==1
replace mccain22miss=w10am_95 if w10amp_v==2
recode mccain22miss -7 -6 -2=1 else=0
gen mccain23=w9amp_96 if w9amp_ve==1
replace mccain23=w10am_96 if w10amp_v==2
recode mccain23 1=1 2=0 else=.
gen mccain23miss=w9amp_96 if w9amp_ve==1
replace mccain23miss=w10am_96 if w10amp_v==2
recode mccain23miss -7 -6 -2=1 else=0
gen mccain24=w9amp_97 if w9amp_ve==1
replace mccain24=w10am_97 if w10amp_v==2
recode mccain24 1=1 2=0 else=.
gen mccain24miss=w9amp_97 if w9amp_ve==1
replace mccain24miss=w10am_97 if w10amp_v==2
recode mccain24miss -7 -6 -2=1 else=0
gen mccainmiss=(mccain1miss+mccain2miss+mccain3miss+mccain4miss+mccain5miss+mccain6miss+mccain7miss+mccain8miss+mccain9miss+mccain10miss+mccain11miss+mccain12miss+mccain13miss+mccain14miss+mccain15miss+mccain16miss+mccain17miss+mccain18miss+mccain19miss+mccain20miss+mccain21miss+mccain22miss+mccain23miss+mccain24miss)

gen candamp1=(1+mccain1-obama1)/2
gen candamp2=(1+mccain2-obama2)/2
gen candamp3=(1+mccain3-obama3)/2
gen candamp4=(1+mccain4-obama4)/2
gen candamp5=(1+mccain5-obama5)/2
gen candamp6=(1+mccain6-obama6)/2
gen candamp7=(1+mccain7-obama7)/2
gen candamp8=(1+mccain8-obama8)/2
gen candamp9=(1+mccain9-obama9)/2
gen candamp10=(1+mccain10-obama10)/2
gen candamp11=(1+mccain11-obama11)/2
gen candamp12=(1+mccain12-obama12)/2
gen candamp13=(1+mccain13-obama13)/2
gen candamp14=(1+mccain14-obama14)/2
gen candamp15=(1+mccain15-obama15)/2
gen candamp16=(1+mccain16-obama16)/2
gen candamp17=(1+mccain17-obama17)/2
gen candamp18=(1+mccain18-obama18)/2
gen candamp19=(1+mccain19-obama19)/2
gen candamp20=(1+mccain20-obama20)/2
gen candamp21=(1+mccain21-obama21)/2
gen candamp22=(1+mccain22-obama22)/2
gen candamp23=(1+mccain23-obama23)/2
gen candamp24=(1+mccain24-obama24)/2

recode obama1 .=0 if obama1miss==1
recode obama2 .=0 if obama2miss==1
recode obama3 .=0 if obama3miss==1
recode obama4 .=0 if obama4miss==1
recode obama5 .=0 if obama5miss==1
recode obama6 .=0 if obama6miss==1
recode obama7 .=0 if obama7miss==1
recode obama8 .=0 if obama8miss==1
recode obama9 .=0 if obama9miss==1
recode obama10 .=0 if obama10miss==1
recode obama11 .=0 if obama11miss==1
recode obama12 .=0 if obama12miss==1
recode obama13 .=0 if obama13miss==1
recode obama14 .=0 if obama14miss==1
recode obama15 .=0 if obama15miss==1
recode obama16 .=0 if obama16miss==1
recode obama17 .=0 if obama17miss==1
recode obama18 .=0 if obama18miss==1
recode obama19 .=0 if obama19miss==1
recode obama20 .=0 if obama20miss==1
recode obama21 .=0 if obama21miss==1
recode obama22 .=0 if obama22miss==1
recode obama23 .=0 if obama23miss==1
recode obama24 .=0 if obama24miss==1

recode mccain1 .=0 if mccain1miss==1
recode mccain2 .=0 if mccain2miss==1
recode mccain3 .=0 if mccain3miss==1
recode mccain4 .=0 if mccain4miss==1
recode mccain5 .=0 if mccain5miss==1
recode mccain6 .=0 if mccain6miss==1
recode mccain7 .=0 if mccain7miss==1
recode mccain8 .=0 if mccain8miss==1
recode mccain9 .=0 if mccain9miss==1
recode mccain10 .=0 if mccain10miss==1
recode mccain11 .=0 if mccain11miss==1
recode mccain12 .=0 if mccain12miss==1
recode mccain13 .=0 if mccain13miss==1
recode mccain14 .=0 if mccain14miss==1
recode mccain15 .=0 if mccain15miss==1
recode mccain16 .=0 if mccain16miss==1
recode mccain17 .=0 if mccain17miss==1
recode mccain18 .=0 if mccain18miss==1
recode mccain19 .=0 if mccain19miss==1
recode mccain20 .=0 if mccain20miss==1
recode mccain21 .=0 if mccain21miss==1
recode mccain22 .=0 if mccain22miss==1
recode mccain23 .=0 if mccain23miss==1
recode mccain24 .=0 if mccain24miss==1

gen obamatotal=(obama1+obama2+obama3+obama4+obama5+obama6+obama7+obama8+obama9+obama10+obama11+obama12+obama13+obama14+obama15+obama16+obama17+obama18+obama19+obama20+obama21+obama22+obama23+obama24)/(24-obamamiss) if obamamiss<2
gen mccaintotal=(mccain1+mccain2+mccain3+mccain4+mccain5+mccain6+mccain7+mccain8+mccain9+mccain10+mccain11+mccain12+mccain13+mccain14+mccain15+mccain16+mccain17+mccain18+mccain19+mccain20+mccain21+mccain22+mccain23+mccain24)/(24-mccainmiss) if mccainmiss<2

gen ampcand=(1+mccaintotal-obamatotal)/2

//registered to vote 
gen registered=.
recode registered .=0 if der25==2|der25==3
recode registered 0=1 if der25==1

gen regdk=.
recode regdk .=0 if der25==1|der25==2
recode regdk .=1 if der25==3

//habitual voting 
gen usuallyvote=.
recode usuallyvote .=0 if der21==2 
recode usuallyvote .=1 if der21==1

//did you vote for Obama (vs McCain) in 2008 wave 11*
gen obama2008=w11a6
recode obama2008 -7/-1=. 3/10=. 13=0 15/17=. 18=1 30=.

gen mccain2008=w11a6
recode mccain2008 -7/-1=. 3/10=. 13=1 15/17=. 18=0 30=.

//turnout in 2008 general
gen turnout=der15
recode turnout -6/-2=. 1=1 2=0 

//Main Voting Behavior DV
gen beh=.
recode beh .=1 if obama2008==1
recode beh .=2 if mccain2008==1
recode beh .=3 if (w11a6>=3 & w11a6<=10)|(w11a6==15)|(w11a6==17)|(w11a6==30)
recode beh .=4 if turnout==0

//Race
gen white=der03a
recode white -6=. 1=1 0=0
gen black=der03b
recode black -6=. 1=1 0=0
gen hisp=der04
recode hisp -6=. 3=1 1 2 4=0
gen raceother=der03a
recode raceother -6=. 0=1 1=0
recode raceother 1=0 if der03b==1

//party id
gen pid7cat=der08w10
recode pid7cat -7/-5=.

gen dem=pid7cat 
recode dem 0 1=1 2/6=0 else=.
gen rep=pid7cat
recode rep 0/4=0 5 6=1 else=.

//Ideology
gen lib=der09w10
recode lib -7/-2=. 4/7=0 1/3=1
gen cons=der09w10
recode cons -7/-2=. 1/4=0 5/7=1

//Age
gen age=der02
gen age0to1=(age-18)/72
gen age0to1sq=(age0to1*age0to1)

gen age18to24=.
recode age18to24 .=0 if age>0 & age<94
recode age18to24 0=1 if age>=18 & age<=24

gen age25to34=.
recode age25to34 .=0 if age>0 & age<94
recode age25to34 0=1 if age>=25 & age<=34

gen age35to44=.
recode age35to44 .=0 if age>0 & age<94
recode age35to44 0=1 if age>=35 & age<=44

gen age45to54=.
recode age45to54 .=0 if age>0 & age<94
recode age45to54 0=1 if age>=45 & age<=54

gen age55to64=.
recode age55to64 .=0 if age>0 & age<94
recode age55to64 0=1 if age>=55 & age<=64

gen age65to74=.
recode age65to74 .=0 if age>0 & age<94
recode age65to74 0=1 if age>=65 & age<=74

gen age75plus=.
recode age75plus .=0 if age>0 & age<94
recode age75plus 0=1 if age>=75 & age<=94

//Racial Resentment
gen raceirish=w20l1
recode raceirish -9/-2=. 5=0 4=.25 3=.5 2=.75 1=1
gen racegenrev=w20l2
recode racegenrev -9/-2=. 1=0 2=.25 3=.5 4=.75 5=1
gen racedesrev=w20l3
recode racedesrev -9/-2=. 1=0 2=.25 3=.5 4=.75 5=1
gen racetry=w20l4
recode racetry -9/-2=. 5=0 4=.25 3=.5 2=.75 1=1

alpha raceirish racegenrev racedesrev racetry, gen(raceres)

//Education
gen educ0to1=der05
recode educ0to1 -2=. 1=0 2=.25 3=.5 4=.75 5=1

gen educnhs=.
recode educnhs .=0 if der05~=. & der05~=-2 & der05~=-6
recode educnhs 0=1 if der05==1

gen educhs=.
recode educhs .=0 if der05~=. & der05~=-2 & der05~=-6
recode educhs 0=1 if der05==2

gen educsc=.
recode educsc .=0 if der05~=. & der05~=-2 & der05~=-6
recode educsc 0=1 if der05==3

gen educcgplus=.
recode educcgplus .=0 if der05~=. & der05~=-2 & der05~=-6
recode educcgplus 0=1 if der05==4|der05==5

//Income
gen income=der06
recode income -2 -6=.
gen inc0to1=(income-1)/18

gen incmiss=der06
recode incmiss -2=1 -6=. else=0
gen inc0to14=income
recode inc0to14 1 2 3 4 5=1 6/19=0
replace inc0to14=0 if incmiss==1

gen inc15to34=income
recode inc15to34 1/5 10/19=0 6/9=1
replace inc15to34=0 if incmiss==1

gen inc35to59=income
recode inc35to59 1/9 13/19=0 10/12=1
replace inc35to59=0 if incmiss==1

gen inc60to74=income
recode inc60to74 1/12 14/19=0 13=1
replace inc60to74=0 if incmiss==1

gen inc75to99=income
recode inc75to99 1/13 16/19=0 14 15=1
replace inc75to99=0 if incmiss==1

gen inc100plus=income
recode inc100plus 16/19=1 1/15=0
replace inc100plus=0 if incmiss==1

//Sex
gen female=.
recode female .=0 if der01~=-6
recode female 0=1 if der01==2

//like or dislike Obama wave 6*
gen likeObamaw6=0
recode likeObamaw6 0=1 if w6e38==2
recode likeObamaw6 0=4 if w6e38==3
recode likeObamaw6 0=7 if w6e38==1
recode likeObamaw6 1=2 if w6e40==2
recode likeObamaw6 1=3 if w6e40==3
recode likeObamaw6 7=6 if w6e39==2
recode likeObamaw6 7=5 if w6e39==3
recode likeObamaw6 0=.
gen likeObamaw60to1=(likeObamaw6-1)/6

gen likeMcCainw6=0
recode likeMcCainw6 0=1 if w6e14==2
recode likeMcCainw6 0=4 if w6e14==3
recode likeMcCainw6 0=7 if w6e14==1
recode likeMcCainw6 1=2 if w6e16==2
recode likeMcCainw6 1=3 if w6e16==3
recode likeMcCainw6 7=6 if w6e15==2
recode likeMcCainw6 7=5 if w6e15==3
recode likeMcCainw6 0=.
gen likeMcCainw60to1=(likeMcCainw6-1)/6

gen molikedif6=(1+likeMcCainw60to1-likeObamaw60to1)/2

//like or dislike Obama wave 9*
gen likeObamaw9=0
recode likeObamaw9 0=1 if w9e38==2
recode likeObamaw9 0=4 if w9e38==3
recode likeObamaw9 0=7 if w9e38==1
recode likeObamaw9 1=2 if w9e40==2
recode likeObamaw9 1=3 if w9e40==3
recode likeObamaw9 7=6 if w9e39==2
recode likeObamaw9 7=5 if w9e39==3
recode likeObamaw9 0=.
gen likeObamaw90to1=(likeObamaw9-1)/6

gen likeMcCainw9=0
recode likeMcCainw9 0=1 if w9e14==2
recode likeMcCainw9 0=4 if w9e14==3
recode likeMcCainw9 0=7 if w9e14==1
recode likeMcCainw9 1=2 if w9e16==2
recode likeMcCainw9 1=3 if w9e16==3
recode likeMcCainw9 7=6 if w9e15==2
recode likeMcCainw9 7=5 if w9e15==3
recode likeMcCainw9 0=.
gen likeMcCainw90to1=(likeMcCainw9-1)/6

gen molikedif9=(1+likeMcCainw90to1-likeObamaw90to1)/2

//like or dislike Obama wave 10
gen likeObamaw10=0
recode likeObamaw10 0=1 if w10e38==2
recode likeObamaw10 0=4 if w10e38==3
recode likeObamaw10 0=7 if w10e38==1
recode likeObamaw10 1=2 if w10e40==2
recode likeObamaw10 1=3 if w10e40==3
recode likeObamaw10 7=6 if w10e39==2
recode likeObamaw10 7=5 if w10e39==3
recode likeObamaw10 0=.
gen likeObamaw100to1=(likeObamaw10-1)/6

gen likeMcCainw10=0
recode likeMcCainw10 0=1 if w10e14==2
recode likeMcCainw10 0=4 if w10e14==3
recode likeMcCainw10 0=7 if w10e14==1
recode likeMcCainw10 1=2 if w10e16==2
recode likeMcCainw10 1=3 if w10e16==3
recode likeMcCainw10 7=6 if w10e15==2
recode likeMcCainw10 7=5 if w10e15==3
recode likeMcCainw10 0=.
gen likeMcCainw100to1=(likeMcCainw10-1)/6

gen molikedif10=(1+likeMcCainw100to1-likeObamaw100to1)/2

gen likedemsw9=0
recode likedemsw9 0=1 if w9e2==2
recode likedemsw9 0=4 if w9e2==3
recode likedemsw9 0=7 if w9e2==1
recode likedemsw9 1=2 if w9e4==2
recode likedemsw9 1=3 if w9e4==3
recode likedemsw9 7=6 if w9e3==2
recode likedemsw9 7=5 if w9e3==3
recode likedemsw9 0=.
gen likedemsw90to1=(likedemsw9-1)/6

gen likerepsw9=0
recode likerepsw9 0=1 if w9e5==2
recode likerepsw9 0=4 if w9e5==3
recode likerepsw9 0=7 if w9e5==1
recode likerepsw9 1=2 if w9e7==2
recode likerepsw9 1=3 if w9e7==3
recode likerepsw9 7=6 if w9e6==2
recode likerepsw9 7=5 if w9e6==3
recode likerepsw9 0=.
gen likerepsw90to1=(likerepsw9-1)/6

gen rdlikedif9=(1+likerepsw90to1-likedemsw90to1)/2

gen likedemsw10=0
recode likedemsw10 0=1 if w10e2==2
recode likedemsw10 0=4 if w10e2==3
recode likedemsw10 0=7 if w10e2==1
recode likedemsw10 1=2 if w10e4==2
recode likedemsw10 1=3 if w10e4==3
recode likedemsw10 7=6 if w10e3==2
recode likedemsw10 7=5 if w10e3==3
recode likedemsw10 0=.
gen likedemsw100to1=(likedemsw10-1)/6

gen likerepsw10=0
recode likerepsw10 0=1 if w10e5==2
recode likerepsw10 0=4 if w10e5==3
recode likerepsw10 0=7 if w10e5==1
recode likerepsw10 1=2 if w10e7==2
recode likerepsw10 1=3 if w10e7==3
recode likerepsw10 7=6 if w10e6==2
recode likerepsw10 7=5 if w10e6==3
recode likerepsw10 0=.
gen likerepsw100to1=(likerepsw10-1)/6

gen rdlikedif10=(1+likerepsw100to1-likedemsw100to1)/2

//like or dislike Obama wave 17*
gen likeObamaw17=0
recode likeObamaw17 0=1 if w17e38==2
recode likeObamaw17 0=4 if w17e38==3
recode likeObamaw17 0=7 if w17e38==1
recode likeObamaw17 1=2 if w17e40==2
recode likeObamaw17 1=3 if w17e40==3
recode likeObamaw17 7=6 if w17e39==2
recode likeObamaw17 7=5 if w17e39==3
recode likeObamaw17 0=.
gen likeObamaw170to1=(likeObamaw17-1)/6

gen likeMcCainw17=0 
recode likeMcCainw17 0=1 if w17e14==2
recode likeMcCainw17 0=4 if w17e14==3
recode likeMcCainw17 0=7 if w17e14==1
recode likeMcCainw17 1=2 if w17e16==2
recode likeMcCainw17 1=3 if w17e16==3
recode likeMcCainw17 7=6 if w17e15==2
recode likeMcCainw17 7=5 if w17e15==3
recode likeMcCainw17 0=.
gen likeMcCainw170to1=(likeMcCainw17-1)/6

gen molikedif17=(1+likeMcCainw170to1-likeObamaw170to1)/2

//Census region 
gen censusne=0
recode censusne 0=1 if wgtregio==1
recode censusne 0=. if wgtregio==-6

gen censusmw=0
recode censusmw 0=1 if wgtregio==2
recode censusmw 0=. if wgtregio==-6

gen censussouth=0
recode censussouth 0=1 if wgtregio==3
recode censussouth 0=. if wgtregio==-6

gen censuswest=0
recode censuswest 0=1 if wgtregio==4
recode censuswest 0=. if wgtregio==-6

//Evaluations 
gen econ=w10u1
recode econ 1=.75 2=.5 3=.25 else=.
recode econ .75=1 if w10u2==1
recode econ .25=0 if w10u3==1

gen bushapp=w10e59
recode bushapp 1=.83 2=.17 3=.5 else=.
recode bushapp .83=1 if w10e60==1
recode bushapp .83=.66 if w10e60==3
recode bushapp .17=0 if w10e61==1
recode bushapp .17=.33 if w10e61==3

//Obama Approval w19
gen obamaapp19=w19ws1
recode obamaapp19 1=.83 2=.17 3=.5 else=.
recode obamaapp19 .83=1 if w19ws_a_==1
recode obamaapp19 .83=.66 if w19ws_a_==3
recode obamaapp19 .17=0 if w19ws_d_==1
recode obamaapp19 .17=.33 if w19ws_d_==3

//Party Likes
gen likedem19=w19e2
recode likedem19 1=.83 2=.17 3=.5 else=.
recode likedem19 .83=1 if w19e3==1
recode likedem19 .83=.66 if w19e3==3
recode likedem19 .17=0 if w19e4==1
recode likedem19 .17=.33 if w19e4==3

gen likerep19=w19e5
recode likerep19 1=.83 2=.17 3=.5 else=.
recode likerep19 .83=1 if w19e6==1
recode likerep19 .83=.66 if w19e6==3
recode likerep19 .17=0 if w19e7==1
recode likerep19 .17=.33 if w19e7==3

gen rdlikedif19=(1+likerep19-likedem19)/2

//Race Policy 
gen collaffact_9=w9qr1
recode collaffact_9 1=.83 2=.17 3=.5 else=.
recode collaffact_9 .83=1 if w9qr2a==1
recode collaffact_9 .83=.66 if w9qr2a==3
recode collaffact_9 .17=0 if w9qr2b==1
recode collaffact_9 .17=.33 if w9qr2b==3

gen jobaffact_11=w11n15_a
recode jobaffact_11 1=.83 2=.17 3=.5 else=.
recode jobaffact_11 .83=1 if w11n15_b==1
recode jobaffact_11 .83=.66 if w11n15_b==3
recode jobaffact_11 .17=0 if w11n15_c==1
recode jobaffact_11 .17=.33 if w11n15_c==3

gen collaffact_13=w13n15
recode collaffact_13 1=.83 2=.17 3=.5 else=.
recode collaffact_13 .83=1 if w13n16_f==1
recode collaffact_13 .83=.66 if w13n16_f==3
recode collaffact_13 .17=0 if w13n16_o==1
recode collaffact_13 .17=.33 if w13n16_o==3

gen jobaffact_13=w13n17
recode jobaffact_13 1=.83 2=.17 3=.5 else=.
recode jobaffact_13 .83=1 if w13n18_f==1
recode jobaffact_13 .83=.66 if w13n18_f==3
recode jobaffact_13 .17=0 if w13n18_o==1
recode jobaffact_13 .17=.33 if w13n18_o==3

gen fairtreat_9=w9zb1
recode fairtreat_9 1=.83 2=.17 3=.5 else=.
recode fairtreat_9 .83=1 if w9zb2_f==1
recode fairtreat_9 .83=.66 if w9zb2_f==3
recode fairtreat_9 .17=0 if w9zb2_o==1
recode fairtreat_9 .17=.33 if w9zb2_o==3

gen fairtreat_11=w11zb1
recode fairtreat_11 1=.83 2=.17 3=.5 else=.
recode fairtreat_11 .83=1 if w11zb2a==1
recode fairtreat_11 .83=.66 if w11zb2a==3
recode fairtreat_11 .17=0 if w11zb2b==1
recode fairtreat_11 .17=.33 if w11zb2b==3

gen fairtreat_17=w17x1
recode fairtreat_17 1=.83 2=.17 3=.5 else=.
recode fairtreat_17 .83=1 if w17x_f_2==1
recode fairtreat_17 .83=.66 if w17x_f_2==3
recode fairtreat_17 .17=0 if w17x_o_2==1
recode fairtreat_17 .17=.33 if w17x_o_2==3

*ANALYSES
//Wave 20 weight used because racial resentment items appear in that wave

*Table 1: The AMP, Explicit Prejudice, and Electoral Behavior in 2008
svyset [pweight=wgtpp20], strata(stratum)
svy: mlogit beh amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp, baseoutcome(1)
svy: mlogit beh amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp, baseoutcome(2)

*Table 2: Testing Timing Effects of AMP administration in the ANES Panel
svy, subpop(if w9amp_ve==2): mlogit beh amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp, baseoutcome(1)
svy, subpop(if w9amp_ve==2): mlogit beh amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp, baseoutcome(2)

svy, subpop(if w10amp_v==1): mlogit beh amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp, baseoutcome(1)
svy, subpop(if w10amp_v==1): mlogit beh amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp, baseoutcome(2)

*Table 3: Associations between the AMP and Evaluations of Candidates & Parties
svy: reg likeObamaw60to1 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg molikedif6 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 

svy: reg likeObamaw90to1 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg molikedif9 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg likedemsw90to1 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg rdlikedif9 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 

svy: reg likeObamaw100to1 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg molikedif10 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg likedemsw100to1 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg rdlikedif10 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 

svy: reg likeObamaw170to1 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg molikedif17 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 

svy: reg obamaapp19 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg likedem19 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 
svy: reg rdlikedif19 amp raceres dem rep lib cons econ bushapp age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp 

*Table 4: Associations between the AMP and Race-Relevant Policy Attitudes
svy: reg fairtreat_9 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
svy: reg collaffact_9 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
svy: reg fairtreat_11 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
svy: reg jobaffact_11 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
svy: reg collaffact_13 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
svy: reg jobaffact_13 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
svy: reg fairtreat_17 amp raceres dem rep lib cons age25to34 age35to44 age45to54 age55to64 age65to74 age75plus educhs educsc educcgplus incmiss inc15to34 inc35to59 inc60to74 inc75to99 inc100plus female black raceother hisp
